home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
ftpser1a
/
ftp_srv.frm
< prev
next >
Wrap
Text File
|
1999-10-04
|
13KB
|
383 lines
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form FtpServ
Appearance = 0 'Flat
AutoRedraw = -1 'True
BackColor = &H00C0C0C0&
BorderStyle = 1 'Fixed Single
Caption = "FTP SERVER"
ClientHeight = 4575
ClientLeft = 1455
ClientTop = 3105
ClientWidth = 8355
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Icon = "FTP_SRV.frx":0000
LinkTopic = "FtpServ"
MaxButton = 0 'False
MinButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 4575
ScaleWidth = 8355
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox UsrCnt
Height = 285
Left = 3240
TabIndex = 5
Text = "0"
Top = 3960
Width = 855
End
Begin VB.CommandButton EndCmd
Caption = "Close Connection"
Height = 375
Left = 120
TabIndex = 3
Top = 3840
Width = 1935
End
Begin VB.Frame StatFrame
Caption = "Status Window"
Height = 3735
Left = 120
TabIndex = 1
Top = 0
Width = 8055
Begin VB.ListBox LogWnd
Appearance = 0 'Flat
BackColor = &H00000000&
BeginProperty Font
Name = "MS Serif"
Size = 6.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 3165
ItemData = "FTP_SRV.frx":030A
Left = 120
List = "FTP_SRV.frx":030C
TabIndex = 2
Top = 240
Width = 7815
End
End
Begin ComctlLib.StatusBar StatusBar
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 0
Top = 4320
Width = 8355
_ExtentX = 14737
_ExtentY = 450
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 3
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 10654
MinWidth = 10654
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 6
Object.Width = 2187
MinWidth = 2187
TextSave = "10/05/1999"
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Style = 5
Object.Width = 1764
MinWidth = 1764
TextSave = "1:55 AM"
Object.Tag = ""
EndProperty
EndProperty
End
Begin VB.Timer Timer1
Enabled = 0 'False
Index = 4
Interval = 50
Left = 7200
Top = 3840
End
Begin VB.Timer Timer1
Enabled = 0 'False
Index = 3
Interval = 50
Left = 6720
Top = 3840
End
Begin VB.Timer Timer1
Enabled = 0 'False
Index = 2
Interval = 50
Left = 6240
Top = 3840
End
Begin VB.Timer Timer1
Enabled = 0 'False
Index = 1
Interval = 50
Left = 5760
Top = 3840
End
Begin VB.Timer Timer1
Enabled = 0 'False
Index = 0
Interval = 50
Left = 5280
Top = 3840
End
Begin VB.Label Label1
Caption = "# of Users"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2280
TabIndex = 4
Top = 3960
Width = 975
End
Begin VB.Menu mSetup
Caption = "Setup"
End
End
Attribute VB_Name = "FtpServ"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub EndCmd_Click()
Dim i As Integer
For i = 1 To MAX_N_USERS 'close all connection
If users(i).control_slot <> INVALID_SOCKET Then
retf = closesocket(users(i).control_slot) 'close control slot
End If
If users(i).data_slot <> INVALID_SOCKET Then
retf = closesocket(users(i).data_slot) 'close data slot
End If
Next
retf = closesocket(ServerSlot)
If SaveProfile(App.Path & "\ftp_srv.ini", True) Then
End If
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim hdr As String, item As String
'--- Initialization
'an FTP command is terminated by Carriage_Return & Line_Feed
'possible sintax errors in FTP commands
sintax_error_list(0) = "200 Command Ok."
sintax_error_list(1) = "202 Command not implemented, superfluous at this site."
sintax_error_list(2) = "500 Sintax error, command unrecognized."
sintax_error_list(3) = "501 Sintax error in parameters or arguments."
sintax_error_list(4) = "502 Command not implemented."
sintax_error_list(6) = "504 Command not implemented for that parameter."
'initializes the list which contains the names,
'passwords, access rights and default directory
'recognized by the server
If LoadProfile(App.Path & "\ftp_srv.ini") Then
'
Else
StatusBar.Panels(1) = "Error Loading Ini File!"
End If
'initializes the records which contain the
'informations on the connected users
For i = 1 To MAX_N_USERS
users(i).list_index = 0
users(i).control_slot = INVALID_SLOT
users(i).data_slot = INVALID_SLOT
users(i).IP_address = ""
users(i).Port = 0
users(i).data_representation = "A"
users(i).data_format_ctrls = "N"
users(i).data_structure = "F"
users(i).data_tx_mode = "S"
users(i).cur_dir = ""
users(i).state = 0
users(i).full = False
Next
OldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
vbWSAStartup
'begins SERVER mode on port 21
ServerSlot = ListenForConnect(21, hWnd)
If ServerSlot > 0 Then
StatusBar.Panels(1) = Description
Else
StatusBar.Panels(1) = "Error Creating Listening Socket"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong hWnd, GWL_WNDPROC, OldWndProc
vbWSACleanup
End Sub
Private Sub mSetup_Click()
UserOpts.Show 1
End Sub
Private Sub Timer1_Timer(index As Integer)
Dim close_data_cnt As Integer
Dim error_on_data_cnt As Integer
Select Case files_info(index).retr_stor
Case 0: '--- R E T R Command
If files_info(index).data_representation = "A" Then
If Not